package com.ohos.connent.accountcloud.biz.modular.org.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.ohos.connent.accountcloud.biz.modular.dp.entity.DpEnterpriseInfo;
import com.ohos.connent.accountcloud.biz.modular.dp.wrapper.DpEnterprisePageWrapper;
import com.ohos.connent.accountcloud.biz.modular.org.param.OrgCertifiedParam;
import com.ohos.connent.accountcloud.biz.modular.org.param.OrgFrozenParam;
import com.ohos.connent.accountcloud.biz.modular.org.param.OrgIdParam;
import com.ohos.connent.accountcloud.biz.modular.org.param.OrgPageParam;
import com.ohos.connent.accountcloud.biz.modular.org.result.EnterpriseDetailResult;
import com.ohos.connent.accountcloud.biz.modular.org.service.OrgService;
import com.ohos.connent.accountcloud.common.annotation.CommonLog;
import com.ohos.connent.accountcloud.common.annotation.CommonWrapper;
import com.ohos.connent.accountcloud.common.pojo.CommonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 运维平台企业管理控制器
 *
 * @Author: ChenJiaHao
 * @Date: 2024/6/7 14:13
 * @Description:
 */
@Api(tags = "运维平台企业管理控制器")
@ApiSupport(author = "OHOSCONNECT_TEAM", order = 10)
@RestController
@Validated
@RequestMapping("/api/v1/account/org")
public class OrgController {

    @Resource
    private OrgService orgService;

    @ApiOperationSupport(order = 1)
    @ApiOperation("企业认证审核列表/已认证企业列表")
    @CommonLog("企业认证审核列表/已认证企业列表")
    @PostMapping("/page")
    @CommonWrapper(value = DpEnterprisePageWrapper.class, isReplacement = true)
    public CommonResult<Page<DpEnterpriseInfo>> page(@RequestBody @Valid OrgPageParam orgPageParam) {
        return CommonResult.data(orgService.page(orgPageParam));
    }

    @ApiOperationSupport(order = 2)
    @ApiOperation("企业明细查看接口")
    @CommonLog("企业明细查看接口")
    @GetMapping("/detail")
    public CommonResult<EnterpriseDetailResult> detail(OrgIdParam orgIdParam) {
        return CommonResult.data(orgService.detail(orgIdParam));
    }

    @ApiOperationSupport(order = 3)
    @ApiOperation("企业审核")
    @CommonLog("企业审核")
    @PostMapping("/certified")
    public CommonResult<String> certified(@RequestBody @Valid OrgCertifiedParam orgCertifiedParam) {
        orgService.certified(orgCertifiedParam);
        return CommonResult.ok();
    }

    @ApiOperationSupport(order = 4)
    @ApiOperation("已认证企业冻结/解冻")
    @CommonLog("已认证企业冻结/解冻")
    @PostMapping("/frozen")
    public CommonResult<String> frozen(@RequestBody @Valid OrgFrozenParam orgFrozenParam) {
        orgService.frozen(orgFrozenParam);
        return CommonResult.ok();
    }
}
